| @@ -1,5 +1,8 @@ | ||
| 1 | 1 | source 'https://rubygems.org' | 
| 2 | 2 |  | 
| 3 | +# Ruby 2.0 is the minimum requirement | |
| 4 | +ruby ['2.0.0', RUBY_VERSION].max | |
| 5 | + | |
| 3 | 6 | # Optional libraries. To conserve RAM, comment out any that you don't need, | 
| 4 | 7 | # then run `bundle` and commit the updated Gemfile and Gemfile.lock. | 
| 5 | 8 | gem 'twilio-ruby', '~> 3.11.5' # TwilioAgent | 
| @@ -158,26 +158,4 @@ module SortableEvents | ||
| 158 | 158 | orders | 
| 159 | 159 | ).collect!(&:last) | 
| 160 | 160 | end | 
| 161 | - | |
| 162 | - # The emulation of Module#prepend provided by lib/prepend.rb does | |
| 163 | - # not work for methods defined after a call of prepend. | |
| 164 | - if Module.method(:prepend).source_location | |
| 165 | - module ClassMethods | |
| 166 | - def can_order_created_events! | |
| 167 | - raise if cannot_create_events? | |
| 168 | - @can_order_created_events = true | |
| 169 | - end | |
| 170 | - | |
| 171 | - def can_order_created_events? | |
| 172 | - !!@can_order_created_events | |
| 173 | - end | |
| 174 | - end | |
| 175 | - | |
| 176 | - def initialize(*args) | |
| 177 | - if self.class.instance_variable_get(:@can_order_created_events) | |
| 178 | - self.class.__send__ :prepend, SortableEvents::AutomaticSorter | |
| 179 | - end | |
| 180 | - super | |
| 181 | - end | |
| 182 | - end | |
| 183 | 161 | end | 
| @@ -278,21 +278,6 @@ class ScenarioImport | ||
| 278 | 278 | yield 'disabled', disabled, boolean if disabled.requires_merge? | 
| 279 | 279 | end | 
| 280 | 280 |  | 
| 281 | - # Unfortunately Ruby 1.9's OpenStruct doesn't expose [] and []=. | |
| 282 | - unless instance_methods.include?(:[]=) | |
| 283 | - def [](key) | |
| 284 | - self.send(sanitize key) | |
| 285 | - end | |
| 286 | - | |
| 287 | - def []=(key, val) | |
| 288 | -        self.send("#{sanitize key}=", val) | |
| 289 | - end | |
| 290 | - | |
| 291 | - def sanitize(key) | |
| 292 | - key.gsub(/[^a-zA-Z0-9_-]/, '') | |
| 293 | - end | |
| 294 | - end | |
| 295 | - | |
| 296 | 281 | def agent_instance | 
| 297 | 282 |        "Agents::#{self.type.updated}".constantize.new | 
| 298 | 283 | end | 
| @@ -1,6 +1,3 @@ | ||
| 1 | -# Module#prepend support for Ruby 1.9 | |
| 2 | -require 'prepend' unless Module.method_defined?(:prepend) | |
| 3 | - | |
| 4 | 1 | require 'active_support' | 
| 5 | 2 |  | 
| 6 | 3 | ActiveSupport.on_load :active_record do | 
| @@ -1,85 +0,0 @@ | ||
| 1 | -# Fake implementation of prepend(), which does not support overriding | |
| 2 | -# inherited methods nor methods that are formerly overridden by | |
| 3 | -# another invocation of prepend(). | |
| 4 | -# | |
| 5 | -# Here's what <Original>.prepend(<Wrapper>) does: | |
| 6 | -# | |
| 7 | -# - Create an anonymous stub module (hereinafter <Stub>) and define | |
| 8 | -# <Stub>#<method> that calls #<method>_without_<Wrapper> for each | |
| 9 | -# instance method of <Wrapper>. | |
| 10 | -# | |
| 11 | -# - Rename <Original>#<method> to #<method>_without_<Wrapper> for each | |
| 12 | -# instance method of <Wrapper>. | |
| 13 | -# | |
| 14 | -# - Include <Stub> and <Wrapper> into <Original> in that order. | |
| 15 | -# | |
| 16 | -# This way, a call of <Original>#<method> is dispatched to | |
| 17 | -# <Wrapper><method>, which may call super which is dispatched to | |
| 18 | -# <Stub>#<method>, which finally calls | |
| 19 | -# <Original>#<method>_without_<Wrapper> which is used to be called | |
| 20 | -# <Original>#<method>. | |
| 21 | -# | |
| 22 | -# Usage: | |
| 23 | -# | |
| 24 | -# class Mechanize | |
| 25 | -# # module with methods that overrides those of X | |
| 26 | -# module Y | |
| 27 | -# end | |
| 28 | -# | |
| 29 | -# unless X.respond_to?(:prepend, true) | |
| 30 | -# require 'mechanize/prependable' | |
| 31 | -# X.extend(Prependable) | |
| 32 | -# end | |
| 33 | -# | |
| 34 | -# class X | |
| 35 | -# prepend Y | |
| 36 | -# end | |
| 37 | -# end | |
| 38 | -class Module | |
| 39 | - def prepend(mod) | |
| 40 | - stub = Module.new | |
| 41 | - | |
| 42 | - mod_id = (mod.name || 'Module__%d' % mod.object_id).gsub(/::/, '__') | |
| 43 | - | |
| 44 | -    mod.instance_methods.each { |name| | |
| 45 | - method_defined?(name) or next | |
| 46 | - | |
| 47 | - original = instance_method(name) | |
| 48 | - next if original.owner != self | |
| 49 | - | |
| 50 | - name = name.to_s | |
| 51 | -      name_without = name.sub(/(?=[?!=]?\z)/) { '_without_%s' % mod_id } | |
| 52 | - | |
| 53 | - arity = original.arity | |
| 54 | - arglist = ( | |
| 55 | - if arity >= 0 | |
| 56 | -          (1..arity).map { |i| 'x%d' % i } | |
| 57 | - else | |
| 58 | -          (1..(-arity - 1)).map { |i| 'x%d' % i } << '*a' | |
| 59 | - end << '&b' | |
| 60 | -      ).join(', ') | |
| 61 | - | |
| 62 | -      if name.end_with?('=') | |
| 63 | -        stub.module_eval %{ | |
| 64 | -          def #{name}(#{arglist}) | |
| 65 | -            __send__(:#{name_without}, #{arglist}) | |
| 66 | - end | |
| 67 | - } | |
| 68 | - else | |
| 69 | -        stub.module_eval %{ | |
| 70 | -          def #{name}(#{arglist}) | |
| 71 | -            #{name_without}(#{arglist}) | |
| 72 | - end | |
| 73 | - } | |
| 74 | - end | |
| 75 | -      module_eval { | |
| 76 | - alias_method name_without, name | |
| 77 | - remove_method name | |
| 78 | - } | |
| 79 | - } | |
| 80 | - | |
| 81 | - include stub | |
| 82 | - include mod | |
| 83 | - end | |
| 84 | - private :prepend | |
| 85 | -end unless Module.method_defined?(:prepend) || Module.private_method_defined?(:prepend) |